package com.jyw.business.obstacles.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jyw.business.obstacles.domain.ObsCbOrderInfo;
import com.jyw.business.obstacles.domain.dto.web.ObsCbOrderInfoQueryDto;
import com.jyw.business.obstacles.domain.vo.web.ObsCbOrderInfoVO;
import com.jyw.business.obstacles.mapper.ObsCbOrderInfoMapper;
import com.jyw.business.obstacles.service.IObsCbOrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


@Service
@Slf4j
public class ObsCbOrderInfoServiceImpl extends ServiceImpl<ObsCbOrderInfoMapper, ObsCbOrderInfo> implements IObsCbOrderInfoService {


    @Override
    public List<ObsCbOrderInfo> getPageCbOrderInfo(ObsCbOrderInfoQueryDto dto) {
        return this.baseMapper.getPageCbOrderInfo(dto);
    }

    @Override
    public ObsCbOrderInfoVO getByInfoId(String id) {
        ObsCbOrderInfo obsCbOrderInfo = this.baseMapper.selectById(id);
        ObsCbOrderInfoVO vo = new ObsCbOrderInfoVO();
        BeanUtils.copyProperties(obsCbOrderInfo, vo);
        vo.setEvaluateFlag(Boolean.FALSE);
        if (!StringUtils.isEmpty(vo.getEvaluateResult())) {
            vo.setEvaluateFlag(Boolean.TRUE);
        }
        if (!StringUtils.isEmpty(vo.getFaultChild())) {
            vo.setFaultType(vo.getFaultType() + "/" + vo.getFaultChild());
        }
        return vo;
    }
}
